<template>
    <div>
        <div v-show="num">
            <span @click="count('-')">-</span>
            <span>{{num}}</span>
        </div>
        <span @click="count('+')">+</span>
        {{person.name}}
    </div>
</template>
<script>
export default {
    props:{
        num:{
            type:Number,
            required:true,
            default:1,
            validator:(value) => {
                return value < 10
            }
        },
        person:{
            type:Object,
            default:function(){
                return {
                    name:'lixd'
                }
            }
        }
    },
    methods:{
        count(str){
            let num;
            if(str === '+'){
                num = this.num + 1;
            }else{
                num = this.num - 1;
            }
            this.$bus.$emit('count',num)
        }
    }
}
</script>
